package com.hemh.controller;

import javax.annotation.Resource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hemh.entity.OmsEmail;
import com.hemh.service.EmailService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Controller
@Api(value = "EMail相关操作的接口")
public class EmailController {	
	
	private final Log logger = LogFactory.getLog(EmailController.class);
	
	@Resource
	private EmailService emailService;
	
	@Value("${spring.mail.properties.from}")
	private String defaultEMailSender;
	
	@PostMapping("/email/sendEMail")
	@ApiOperation(value = "发送邮件接口")
	@ResponseBody
	public void sendEMail(@RequestParam String emailRecevier, 
			@RequestParam String emailTitle, 
			@RequestParam String emailContent) {
		logger.info("--->>>邮件发送");		
		OmsEmail email = new OmsEmail();
		email.setEmailSender(defaultEMailSender);//默认个人为发送者
		email.setEmailRecevier(emailRecevier);
		email.setEmailTitle(emailTitle);
		email.setEmailContent(emailContent);
		emailService.sendMimeMail(email);
	}

}
